import Vue from 'vue';
import VueRouter from "vue-router"

Vue.use(VueRouter)
const router = new VueRouter({
    mode: "history",
    routes: [
        {
            path: "/",
            redirect: "/index",
        }, {
            path: "/index",
            name: "index",
            component: () => import("@/views/Home/index.vue"),
            meta: {
                title: "首页-主题客"
            }
        },
        // 专栏发文
        {
            path: "/column",
            name: "column",
            component: () => import("@/views/Column/index.vue"),
            meta: {
                title: "专栏发文-主题客"
            },
            children: [{
                path: "",
                redirect: "/column-basic",
            }, {
                path: "/column/basic",
                name: "column-basic",
                component: () => import("@/views/Column/basic"),
                meta: {
                    title: "基本信息-主题客"
                },
            }, {
                path: "/column/list",
                name: "column-list",
                component: () => import("@/views/Column/List"),
                meta: {
                    title: "专栏目录-主题客"
                },
            }, {
                path: "/column/setUp",
                name: "column-setUp",
                component: () => import("@/views/Column/setUp"),
                meta: {
                    title: "专栏运营-主题客"
                },
            }, {
                path: "/column/user",
                name: "column-user",
                component: () => import("@/views/Column/user"),
                meta: {
                    title: "用户列表-主题客"
                },
            }]
        },
        // 目录发文
        {
            path: "/columnPost",
            name: "columnPost",
            component: () => import("@/views/ColumnPost/index.vue"),
            meta: {
                title: "目录发文-主题客"
            },
            children: [{
                path: "",
                redirect: "/columnPost/List",
            }, {
                path: "/columnPost/List",
                name: "columnPost-list",
                component: () => import("@/views/ColumnPost/List"),
                meta: {
                    title: "目录发文-主题客"
                },
            }, {
                path: "/columnPost/library",
                name: "columnPost-library",
                component: () => import("@/views/ColumnPost/library"),
                meta: {
                    title: "文库发文-主题客"
                },
            }, {
                path: "/columnPost/resource",
                name: "columnPost-resource",
                component: () => import("@/views/ColumnPost/resource"),
                meta: {
                    title: "资源库目录-主题客"
                },
            }]
        },

        // 专栏阅读
        {
            path: "/columnRead",
            name: "columnRead",
            component: () => import("@/views/ColumnRead/index.vue"),
            meta: {
                title: "专栏阅读-主题客"
            }
        },

        // 专栏阅读
        {
            path: "/columnIndex",
            name: "columnIndex",
            component: () => import("@/views/ColumnIndex/index.vue"),
            meta: {
                title: "专栏首页-主题客"
            }
        },
        // 专栏文章
        {
            path: "/articleRead",
            name: "articleRead",
            component: () => import("@/views/ColumnArticle/index.vue"),
            meta: {
                title: "专栏阅读-主题客"
            }
        },
        // 社群
        {
            path: "/association",
            name: "association",
            component: () => import("@/views/association/index.vue"),
            meta: {
                title: "社群-主题客"
            }, children: [{
                path: "",
                redirect: "/association/column",
            }, {
                path: "/association/youping",
                name: "association-youping",
                component: () => import("@/views/association/columnY"),
                meta: {
                    title: "优品-社群"
                },
            }, {
                path: "/association/column",
                name: "association-column",
                component: () => import("@/views/association/columnZ"),
                meta: {
                    title: "专栏-社群"
                },
            }, {
                path: "/association/common",
                name: "association-common",
                component: () => import("@/views/association/columnC"),
                meta: {
                    title: "常用-社群"
                },
            }, {
                path: "/association/library",
                name: "association-library",
                component: () => import("@/views/association/library"),
                meta: {
                    title: "文库-社群"
                },
            }, {
                path: "/association/excerpt",
                name: "association-excerpt",
                component: () => import("@/views/association/excerpt"),
                meta: {
                    title: "摘抄-社群"
                },
            }, {
                path: "/association/friends",
                name: "association-friends",
                component: () => import("@/views/association/friends"),
                meta: {
                    title: "好友-社群"
                },
            }, {
                path: "/association/fans",
                name: "association-fans",
                component: () => import("@/views/association/fans"),
                meta: {
                    title: "粉丝-社群"
                },
            }]
        },
        // 知识仓
        {
            path: "/knowledge",
            name: "knowledge",
            component: () => import("@/views/knowledge/index.vue"),
            meta: {
                title: "社群-主题客"
            },
            children: [{
                path: "",
                redirect: "/knowledge/column",
            }, {
                path: "/knowledge/column",
                name: "knowledge-column",
                component: () => import("@/views/knowledge/column"),
                meta: {
                    title: "专栏-知识仓"
                },
            }, {
                path: "/knowledge/library",
                name: "knowledge-library",
                component: () => import("@/views/knowledge/library"),
                meta: {
                    title: "文库-知识仓"
                },
            }, {
                path: "/knowledge/excerpt",
                name: "knowledge-excerpt",
                component: () => import("@/views/knowledge/excerpt"),
                meta: {
                    title: "摘抄-知识仓"
                },
            }, {
                path: "/knowledge/comment",
                name: "knowledge-comment",
                component: () => import("@/views/knowledge/comment"),
                meta: {
                    title: "评论-知识仓"
                },
            }]
        },
        // 资源库
        {
            path: "/resource",
            name: "resource",
            component: () => import("@/views/Resource/index.vue"),
            meta: {
                title: "资源库-主题客"
            },
            children: [{
                path: "",
                redirect: "/resource/column",
            }, {
                path: "/resource/column",
                name: "resource-column",
                component: () => import("@/views/Resource/column"),
                meta: {
                    title: "资源库-主题客"
                },
            }, {
                path: "/resource/read",
                name: "resource-read",
                component: () => import("@/views/Resource/Read"),
                meta: {
                    title: "资源库-主题客"

                },
            }, {
                path: "/resourceIndex",
                name: "resourceIndex",
                component: () => import("@/views/ResourceIndex/index.vue"),
                meta: {
                    title: "资源库-主题客"

                },
            },
            ]
        },
        //私享会
        {
            path: "/shareClub",
            name: "shareClub",
            component: () => import("@/views/shareClub/index.vue"),
            meta: {
                title: "私享会-主题客"
            },
            children: [{
                path: "",
                redirect: "/shareClub/list",
            }, {
                path: "/shareClub/list",
                name: "shareClub-list",
                component: () => import("@/views/shareClub/List"),
                meta: {
                    title: "目录-私享会"
                },
            }, {
                path: "/shareClub/library",
                name: "shareClub-library",
                component: () => import("@/views/shareClub/library"),
                meta: {
                    title: "文库-私享会"
                },
            }, {
                path: "/shareClub/excerpt",
                name: "shareClub-excerpt",
                component: () => import("@/views/shareClub/excerpt"),
                meta: {
                    title: "摘抄-私享会"
                },
            }, {
                path: "/shareClub/user",
                name: "shareClub-user",
                component: () => import("@/views/shareClub/user"),
                meta: {
                    title: "会员-私享会"
                },
            }, {
                path: "/shareClub/collaborate",
                name: "shareClub-collaborate",
                component: () => import("@/views/shareClub/collaborate"),
                meta: {
                    title: "协作-私享会"
                },
            }]
        },
        //朋友圈
        {
            path: "/firendCircle",
            name: "firendCircle",
            component: () => import("@/views/firendCircle/index.vue"),
            meta: {
                title: "朋友圈-主题客"
            }
        },
        //排行榜
        {
            path: "/Ranking",
            name: "Ranking",
            component: () => import("@/views/Ranking"),
            meta: {
                title: "排行榜-主题客"
            }
        },
        //互动
        {
            path: "/interact",
            name: "interact",
            component: () => import("@/views/interact/index.vue"),
            meta: {
                title: "朋友圈-主题客"
            }
        },
        //严选
        {
            path: "/highQuality",
            name: "highQuality",
            component: () => import("@/views/highQuality/index.vue"),
            meta: {
                title: "严选-主题客"
            }
        },

        //通知
        {
            path: "/notice",
            name: "notice",
            component: () => import("@/views/notice/index.vue"),
            meta: {
                title: "通知-主题客"
            },
            children: [
                {
                    path: "",
                    redirect: "/notice/messages",
                }, {
                    path: "/notice/messages",
                    name: "notice-messages",
                    component: () => import("@/views/notice/messages"),
                    meta: {
                        title: "通知私信-主题客"
                    },
                }, {
                    path: "/notice/application",
                    name: "notice-application",
                    component: () => import("@/views/notice/application"),
                    meta: {
                        title: "申请管理-主题客"
                    },
                }, {
                    path: "/notice/report",
                    name: "notice-report",
                    component: () => import("@/views/notice/report"),
                    meta: {
                        title: "举报管理-主题客"
                    },
                }]
        },
        //推广
        {
            path: "/promotion",
            name: "promotion",
            component: () => import("@/views/promotion/index.vue"),
            meta: {
                title: "推广-主题客"
            },
            children: [
                {
                    path: "",
                    redirect: "/promotion/article",
                }, {
                    path: "/promotion/article",
                    name: "promotion-article",
                    component: () => import("@/views/promotion/article"),
                    meta: {
                        title: "社区严选-主题客"
                    },
                }, {
                    path: "/promotion/articleDetail",
                    name: "promotion-articleDetail",
                    component: () => import("@/views/promotion/article/detail.vue"),
                    meta: {
                        title: "社区严选-主题客"
                    },
                }, {
                    path: "/promotion/groupBuy",
                    name: "promotion-groupBuy",
                    component: () => import("@/views/promotion/groupBuy"),
                    meta: {
                        title: "专栏拼团-主题客"
                    },
                }, {
                    path: "/promotion/groupBuyUpdate",
                    name: "promotion-groupBuyUpdate",
                    component: () => import("@/views/promotion/groupBuy/update.vue"),
                    meta: {
                        title: "专栏拼团-主题客"
                    },
                }, {
                    path: "/promotion/advert",
                    name: "promotion-advert",
                    component: () => import("@/views/promotion/advert"),
                    meta: {
                        title: "广告推广-主题客"
                    },
                }, {
                    path: "/promotion/advertApply",
                    name: "promotion-advertApply",
                    component: () => import("@/views/promotion/advert/apply.vue"),
                    meta: {
                        title: "广告推广-主题客"
                    },
                }]
        },
        //钱包
        {
            path: "/moneyBag",
            name: "moneyBag",
            component: () => import("@/views/moneyBag/index.vue"),
            meta: {
                title: "钱包-主题客"
            },
            children: [
                {
                    path: "",
                    redirect: "/moneyBag/detailInfo",
                }, {
                    path: "/moneyBag/detailInfo",
                    name: "moneyBag-detailInfo",
                    component: () => import("@/views/moneyBag/detailInfo"),
                    meta: {
                        title: "收支明细-主题客"
                    },
                }, {
                    path: "/moneyBag/myBag",
                    name: "moneyBag-myBag",
                    component: () => import("@/views/moneyBag/myBag"),
                    meta: {
                        title: "我的钱包-主题客"
                    },
                }, {
                    path: "/moneyBag/recharge",
                    name: "moneyBag-recharge",
                    component: () => import("@/views/moneyBag/recharge"),
                    meta: {
                        title: "充值-主题客"
                    },
                }, {
                    path: "/moneyBag/exchange",
                    name: "moneyBag-exchange",
                    component: () => import("@/views/moneyBag/exchange"),
                    meta: {
                        title: "提现-主题客"
                    },
                }, {
                    path: "/moneyBag/discount",
                    name: "moneyBag-discount",
                    component: () => import("@/views/moneyBag/discount"),
                    meta: {
                        title: "折现-主题客"
                    },
                }, {
                    path: "/moneyBag/myGift",
                    name: "moneyBag-myGift",
                    component: () => import("@/views/moneyBag/myGift"),
                    meta: {
                        title: "我的礼物-主题客"
                    },
                }, {
                    path: "/moneyBag/helpSell",
                    name: "moneyBag-helpSell",
                    component: () => import("@/views/moneyBag/helpSell"),
                    meta: {
                        title: "我的佣金-主题客"
                    },
                },
            ]
        },
        //文章
        {
            path: "/article",
            name: "article",
            component: () => import("@/views/article/index.vue"),
            meta: {
                title: "用户须知-主题客"
            }
        },
        //综合搜索
        {
            path: "/searchAll",
            name: "searchAll",
            component: () => import("@/views/searchAll/index.vue"),
            meta: {
                title: "综合搜索-主题客"
            }
        },
        //首页搜索
        {
            path: "/searchHome",
            name: "searchHome",
            component: () => import("@/views/searchHome/index.vue"),
            meta: {
                title: "首页搜索-主题客"
            }
        },
        {
            path: "/404",
            name: "404",
            component: () => import("@/views/404.vue")
        },
        {
            path: "*",
            redirect: "/404"
        }
    ]
})
const originalPush = VueRouter.prototype.push;
VueRouter.prototype.push = function (location) {
    return originalPush.call(this, location).catch(err => err)
};
let token = localStorage.getItem('token');
router.beforeEach((to, from, next) => {
    // 设置页面标题
    if (to.meta.title) {
        document.title = to.meta.title;
    }
    next();
    // window.scrollTo(0, 0)
    // if (to.meta.title == '首页-主题客' || token) {

    // }
});

export default router